<?php
require('includes/top.php');


foreach($_POST as $key => $value)
{
if($value!="" && $value!="Save")
{

$data = $key.'_'.$value;

$laptop_remarks_array = explode('_',$data);
if($laptop_remarks_array[0]=="laptopremarks" || $laptop_remarks_array[0]=="assignedlap")
{
$type = 'laptop';
$remarks = $laptop_remarks_array[2];
}
elseif($laptop_remarks_array[0]=="accessoriesremarks" || $laptop_remarks_array[0]=="assigned")
{
$type = 'accessories';
$remarks = $laptop_remarks_array[2];
}


$product_id = $laptop_remarks_array[1];
$sql="INSERT INTO approved_replacement(`product_id`,`remarks`,type) VALUES ('$product_id','$remarks','$type')";
$sql1="UPDATE replacement_request SET `approved` = '1' WHERE product_id  = '".trim($product_id)."'";
$result1=mysql_query($sql1);

$result=mysql_query($sql);
}

}

if($result>0)
{
header('Location:approve_replacement.php?v=success');
}
else
{
header('Location:approve_replacement.php?v=err');
}
?>